package com.droowa.model.service;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.BusinessRecord;
import com.droowa.model.dao.BusinessRecordDAO;
import com.droowa.util.BusinessRecordPagingBean;

@Service
public class BusinessRecordServiceImpl implements BusinessRecordService{
	
	@Autowired
	private BusinessRecordDAO dao;

	@Override
	public int joinBusinessRecord(BusinessRecord businessRecord)
			throws SQLException {
		return dao.insertBusinessRecord(businessRecord);
	}

	@Override
	public int removeBusinessRecord(String businessNo) throws SQLException {
		return dao.deleteBusinessRecord(businessNo);
	}

	@Override
	public int modifyBusinessRecord(BusinessRecord businessRecord)
			throws SQLException {
		return dao.updateBusinessRecord(businessRecord);
	}

	@Override
	public List<BusinessRecord> getBusinessRecord() throws SQLException {
		return dao.selectBusinessRecord();
	}

	@Override
	public Map getBusinessRecordByAll(
			HashMap map) throws SQLException {
		List<BusinessRecord> list = dao.selectBusinessRecordByAll(map);
		System.out.println(map.get("page"));
		System.out.println(map.get("sort"));
		BusinessRecordPagingBean pb = new BusinessRecordPagingBean(dao.selectRowCount(map), (int)map.get("page"));
		HashMap resultMap = new HashMap();
		resultMap.put("businessRecord_list", list);
		resultMap.put("paging", pb);
		return resultMap;
	}

	
}
